home *** CD-ROM | disk | FTP | other *** search
Wrap
/* ** $VER: Crop.ieb 1.21, IE Arexx script ** Image Engineer Batch Processing script ** Copyright © by Patrik M Nydensten ** 2/2 1997 Stockholm/Sweden ** ** Crop image with Xoff, Yoff, Width and Height. */ options results signal on error parse arg input command input = upper(strip(input)) address 'IMAGEENGINEER' select /* Required batch script commands */ when input = 'INFO' then return get_info() when input = 'CONFIG' then return get_config(command) when input = 'PROCESS' then return process_image(command) otherwise do 'REQUEST' '"Failure in call to batch script!"' '" Quit "' return '<ERROR>' end end exit 0 /* Required "Get_info" procedure ------------------------------------ */ /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files */ get_info: back = 'OK' return back /* Required "Get_config" procedure ---------------------------------- */ get_config: parse arg '"'command'"' Xoff=0 ; Yoff=0 ; type = 9 ; Width=128 ; Height=128 ; XXoff=100 ; YYoff=100 ; BXoff=-10 ; BYoff=-10 if command ~= '' then parse var command Xoff Yoff '#'type Width Height XXoff YYoff BXoff BYoff . 'IE_TO_FRONT' form = 'FORM "Crop" " OK | Cancel "', ' INTEGER,"X offset",0,4096,'Xoff',SLIDER', ' INTEGER,"Y offset",0,4096,'Yoff',SLIDER' if command = '' then form = form||' CYCLE,"Type:","Use Width & Height|Use X2 & Y2 offset|Use X & Y back offset",0' if (type=0)|(type=9) then form = form||' INTEGER,"Width",2,4096,'Width',SLIDER', ' INTEGER,"Height",2,4096,'Height',SLIDER' if (type=1)|(type=9) then form = form||' INTEGER,"X2 offset",0,4096,'XXoff',SLIDER', ' INTEGER,"Y2 offset",0,4096,'YYoff',SLIDER' if (type=2)|(type=9) then form = form||' INTEGER,"X back offset",-4096,0,'BXoff',SLIDER', ' INTEGER,"Y back offset",-4096,0,'BYoff',SLIDER' if command = '' then do form parse var result ok Xoff Yoff type Width Height XXoff YYoff BXoff BYoff . if ok = 0 then return '<ERROR>' end else do form parse var result ok Xoff Yoff a b . if ok = 0 then return '<ERROR>' if type = 0 then do; Width = a; Height = b; end if type = 1 then do; XXoff = a; YYoff = b; end if type = 2 then do; BXoff = a; BYoff = b; end type = 'none' end back = Xoff Yoff '#'type Width Height XXoff YYoff BXoff BYoff return back /* Required "Process_image" procedure ------------------------------- */ process_image: parse arg '"'src_image'"' '"'dst_image'"' '"'options'"' parse var options Xoff Yoff '#'type Width Height XXoff YYoff BXoff BYoff . 'OPEN' '"'src_image'"' '24' if (RC ~= 0) then do 'IE_TO_FRONT' 'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "' return '<ERROR>' end else LoadImage = result 'PROJECT_INFO' LoadImage 'WIDTH' /* Get width of image */ IW = RESULT 'PROJECT_INFO' LoadImage 'HEIGHT' /* Get height of image */ IH = RESULT if type = 0 then do XXoff = Xoff + Width -1 YYoff = Yoff + Height -1 end if type = 2 then do XXoff = IW + BXoff YYoff = IH + BYoff end if Xoff > IW then Xoff = IW if Yoff > IH then Yoff = IH if XXoff > IW then XXoff = IW if YYoff > IH then YYoff = IH if XXoff < 0 then XXoff = 0 if YYoff < 0 then YYoff = 0 'CROP' LoadImage min(Xoff,XXoff) min(Yoff,YYoff) max(Xoff,XXoff) max(Yoff,YYoff) OutputImage = Result 'CLOSE' LoadImage if getclip('cfg_save_frmt')='' then setclip('cfg_save_frmt','ILBM CmpByteRun1') 'SAVE_DATA' OutputImage '"'dst_image'"' '"'getclip('cfg_save_frmt')'"' if (RC ~= 0) then do 'IE_TO_FRONT' 'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "' return '<ERROR>' end 'CLOSE' OutputImage back = 'OK' return back /* Internal procedures ---------------------------------------------- */ /*******************************************************************/ /* This is where control goes when an error code is returned by IE */ /* It puts up a message saying what happened and on which line */ /*******************************************************************/ error: if RC=5 then do IE_TO_FRONT LAST_ERROR 'REQUEST "'||RESULT||'"' end else do IE_TO_FRONT LAST_ERROR 'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!' end return '<ERROR>'